package o;

import android.content.Context;
import android.content.Intent;
import android.os.AsyncTask;
import android.text.SpannableString;
import android.view.View;
import huawei.widget.HwButton;
import java.lang.ref.WeakReference;
import java.util.List;
import java.util.Locale;
import o.czk.g;

public class dbe extends AsyncTask<HwButton, Void, czn> {
    private WeakReference<View> ˊ;
    private WeakReference<HwButton> ˎ;
    private Context ॱ;

    protected /* synthetic */ Object doInBackground(Object[] objArr) {
        return ˏ((HwButton[]) objArr);
    }

    protected /* synthetic */ void onPostExecute(Object obj) {
        ˎ((czn) obj);
    }

    public dbe(Context context, View view, HwButton hwButton) {
        this.ॱ = context;
        this.ˎ = new WeakReference(hwButton);
        this.ˊ = new WeakReference(view);
    }

    protected czn ˏ(HwButton... hwButtonArr) {
        List ˎ = ((czu) dbn.ˎ(czu.class)).ˎ(true, 1);
        czn o_czn = new czn();
        if (ˎ.isEmpty()) {
            o_czn.ˎ = false;
            o_czn.ॱ = "";
            return o_czn;
        }
        o_czn.ˊ = true;
        dbf ˋ = dbf.ˋ(ˎ);
        if (ˋ.ˋ == ˋ.ॱ) {
            o_czn.ˎ = false;
            o_czn.ॱ = this.ॱ.getString(g.ॱᐝ).toUpperCase(Locale.getDefault());
        } else if (ˋ.ˊ > 0 && ˋ.ˊ + ˋ.ॱ == ˋ.ˋ) {
            o_czn.ˎ = true;
            o_czn.ॱ = this.ॱ.getString(g.ॱᐝ).toUpperCase(Locale.getDefault());
            o_czn.ˋ = true;
        } else if (ˋ.ˎ <= 0 || (ˋ.ˎ + ˋ.ˊ) + ˋ.ॱ != ˋ.ˋ) {
            CharSequence spannableString;
            o_czn.ˎ = true;
            String ˊ = epw.ˊ(ˋ.ʽ);
            if (ˋ.ʻ > 0) {
                String ˊ2 = epw.ˊ(ˋ.ˏ);
                Object toUpperCase = this.ॱ.getString(g.ˊᐝ, new Object[]{ˊ, ˊ2}).toUpperCase(Locale.getDefault());
                spannableString = new SpannableString(toUpperCase);
                int indexOf = toUpperCase.indexOf(ˊ2);
                if (indexOf != -1) {
                    spannableString.setSpan(chm.ॱ, indexOf, ˊ2.length() + indexOf, 33);
                }
            } else {
                spannableString = new SpannableString(this.ॱ.getString(g.ˍ, new Object[]{ˊ}).toUpperCase(Locale.getDefault()));
            }
            o_czn.ॱ = spannableString;
        } else {
            o_czn.ˎ = true;
            o_czn.ॱ = this.ॱ.getString(g.ʼॱ).toUpperCase(Locale.getDefault());
            o_czn.ˏ = true;
        }
        return o_czn;
    }

    protected void ˎ(czn o_czn) {
        super.onPostExecute(o_czn);
        View view = (View) this.ˊ.get();
        if (o_czn.ˊ) {
            if (view != null) {
                view.setVisibility(0);
            }
            HwButton hwButton = (HwButton) this.ˎ.get();
            if (hwButton != null) {
                hwButton.setEnabled(o_czn.ˎ);
                hwButton.setText(o_czn.ॱ);
                hwButton.setTag(o_czn);
                if (o_czn.ˎ) {
                    hwButton.setTextColor(this.ॱ.getResources().getColor(czk$a.ˋ));
                } else {
                    hwButton.setTextColor(this.ॱ.getResources().getColor(czk$a.ʼ));
                }
            }
        } else if (view != null) {
            view.setVisibility(8);
            ll.ˏ(this.ॱ).ˋ(new Intent("notify.listview.refresh_broadcast"));
        }
    }
}
